<template>
  <div class="app-container">
    <el-button @click="bindTesterclick">点击绑定微信用户成体验者</el-button>
    <el-button @click="getbindTesterclick">点击获取体验者列表</el-button>
    <el-button @click="unbindTesterclick">点击解除绑定微信用户成体验者</el-button>

    <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
      <el-form ref="form" :model="form"  label-width="80px">
        <el-row>
          <el-col :span="8" >
            <el-form-item label="微信号" prop="name">
              <el-input v-model="form.wechatid" placeholder="请输入微信号"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="unbindtitle" :visible.sync="unbindopen" width="900px" append-to-body>
      <el-form ref="unbinform" :model="unbinform"  label-width="80px">
        <el-row>
          <el-col :span="8" >
            <el-form-item label="微信号" prop="name">
              <el-input v-model="unbinform.wechatid" placeholder="请输入微信号"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="unbindsubmitForm">确 定</el-button>
        <el-button @click="unbindcancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {bindTesterRequest,getbindTesterRequesr,unbindTesterRequest} from "@/api/applet/authorization";

export default {
  name: "Info",
  components: {

  },
  data() {
    return {
      unbindtitle:"",
      unbindopen:false,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      unbinform:{}
    };
  },
  created() {

  },
  methods: {
    //
    bindTesterclick(){
      this.title ="绑定微信用户成体验者"
      this.open = true;
    },
    getbindTesterclick(){
      console.log(123)
      getbindTesterRequesr().then(response => {
        console.log("体验者列表"+response)
      })
    },
    unbindTesterclick(){
      this.unbindtitle = "解除绑定";
      this.unbindopen = true;
    },

    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        console.log(this.form)
        bindTesterRequest(this.form).then(response => {
          console.log("绑定成功"+response)
        })
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
    },
    /** 提交按钮 */
    unbindsubmitForm() {
      this.$refs["unbinform"].validate(valid => {
        console.log(this.unbinform)
        unbindTesterRequest(this.unbinform).then(response => {
          console.log("解除绑定成功"+response)
        })
      });
    },
    // 取消按钮
    unbindcancel() {
      this.unbindopen = false;
    }

  }
};
</script>
